The term platform is used to refer to a processor/hardware and operating system combination. Binary translators allow binaries built for a particular platform (source) to execute on another platform (target) by translating the machine instructions present in the binary code into equivalent instructions of the target platform. Binary translation can be performed either statically, wherein a new binary image is created for running directly on the target platform, or dynamically wherein the translation takes place while the binary is executed. Different types of binary translators are described by Erik R. Altman, David Kaeli, and Yaron Sheffer, in “Welcome to the Opportunities of Binary Translation.”, IEEE Computer, 33 (3), March 2000, pp 40-45.
Dynamic binary translators (DBTs) follow the execution path of the source binary, perform on-the-fly translation, store the translated code in a translation cache and finally execute the translated code. The translation may be stored in memory, as described by C. Zheng and C.
Thompson in “PA-RISC to IA-64: Transparent execution, no recompilation.”, IEEE Computer, 33(3):47-52, March 2000. Alternatively, the translation may be stored on disk for use across executions of the same binary as described by R. J. Hookway and M. A. Herdeg.in “Digital FX!32: Combining emulation and binary translation.”, Digital Technical Journal, 9(1):3-12, 1997.
Conventional DBTs translate machine instructions from source to target platform using the following phases:                Decode the input instruction        Select target instructions        Optimize the selected instructions        Emit the optimized code into translation cache        
The translated code produced by such DBTs is native to the processor on which it is to be run and as such, can provide performance close to native compiled binaries. However, for this to be the case the cost of translation, which is an overhead on the runtime of the binary needs to be minimised while not compromising on quality of generated code. This is discussed further by M. Probst, in “Fast machine-adaptable dynamic binary translation.”, Proceedings of the Workshop on Binary Translation, Barcelona, Spain, September 2001.
Frederick Smith, Dan Grossman, Greg Morrisett, Luke Hornof, & Trevor Jim, “Compiling for run-time code generation (extended version).”, Technical Report, October 2000, Department of Computer Science, Cornell University, describes the Cyclone programming language that provides explicit support for dynamic specialization of Cyclone routines using precompiled templates and a facility for optimising the templates. Also, Masuhara, H. and Yonezawa, A. “Run-time Bytecode Specialization: A Portable Approach to Generating Optimized Specialized Code.”, Lecture Notes in Computer Science, 2001, describes a run-time technique that operates on bytecode programs in Java Virtual Machine Language. Using this technique the Java bytecode programs are specialized and optimised at runtime. Both these efforts exploit the greater information available at runtime to specialize (or partially evaluate) the program thereby improving performance. However, such optimizations are opportunistic and cannot be applied for all input situations.
If the translated code is to be used on a processor or processors with a parallel processing capability then the binary code needs to be analysed so that the code execution can be scheduled appropriately. In other words, any data dependencies need to be identified and the instructions grouped accordingly. Such analysis is a relatively complex process and is an overhead in the translation process. This overhead becomes particularly prevalent in dynamic translation.
In summary, decoding and analysis of source instructions using traditional DBTs incurs a significant performance overhead resulting in the translated programs running less efficiently.
It is an object of the present invention to provide a method and apparatus for generating code for scheduling the execution of binary code, which avoids some of the above disadvantages or at least provides the public with a useful choice.